<template>
  <el-tooltip :content="getTitle" placement="bottom">
    <span @click="toggle" class="cursor-pointer" :class="$attrs.class">
        <Icon icon="akar-icons:full-screen" v-if="!isFullscreen" ></Icon>
        <Icon icon="akar-icons:normal-screen" v-else></Icon>
      </span>
  </el-tooltip>
</template>
<script lang="ts">
  import { defineComponent, computed, unref } from 'vue';
  import { Tooltip } from 'ant-design-vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useFullscreen } from '@vueuse/core';
  import { Icon } from '/@/components/Icon'

  import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons-vue';
  export default defineComponent({
    name: 'FullScreen',
    components: { FullscreenExitOutlined, FullscreenOutlined, Tooltip, Icon },

    setup() {
      const { t } = useI18n();
      const { toggle, isFullscreen } = useFullscreen();

      const getTitle = computed(() => {
        return unref(isFullscreen)
          ? t('layout.header.tooltipExitFull')
          : t('layout.header.tooltipEntryFull');
      });

      return {
        getTitle,
        isFullscreen,
        toggle,
      };
    },
  });
</script>
